"""截图工具"""
from PIL import ImageGrab
from config.settings import Config


def do_screenshot(x1, y1, x2, y2, screenshot_name):
    """截图功能"""
    try:
        box = (x1, y1, x2, y2)
        screenshot = ImageGrab.grab(bbox=box)
        image_path = f'{Config.SCREENSHOT_DIR}/{screenshot_name}.png'
        screenshot.save(image_path)
        return True
    except Exception as e:
        print(f'│ 截图失败，错误信息：{e}')
        return False
